/**
 * Created by guo.xiaomin on 2017-12-12.
 */
var messageUtil = require('../common/utils/messageUtil');
var userInvitationService = require('../services/userInvitationService');


exports.bindInviterAndInvitee = function (req, res) {
    // 邀请人手机号
    var inviterMobilePhone = req.body.inviterMobilePhone;
    // 被邀请人手机号
    var inviteeMobilePhone = req.body.inviteeMobilePhone;
    userInvitationService.bindInviterAndInvitee(inviterMobilePhone, inviteeMobilePhone, function(err, results) {
        if (err) {
            logger.error('Failed to bindInviterAndInvitee ---' + err.message);
            res.json(messageUtil.composeFailedMessage(req, err.message, ''));
        } else {
            logger.debug('success to bindInviterAndInvitee ---');
            res.json(messageUtil.composeSucceededMessage(req, null, results, ''));
        }
    });

};